<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../commons/taglibs.jsp"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<%@include file="../commons/meta.jsp"%>

<base href="<%=basePath%>">

<title>修改密码</title>

<script type="text/javascript" src="javascript/jquery-1.11.0.js"></script>
<link rel="stylesheet" href="javascript/v2/css/bootstrap-responsive.css">
<link rel="stylesheet" href="javascript/v2/css/bootstrap.css">
<script src="javascript/v2/js/bootstrap.js"></script>
<script src="javascript/md5.js"></script>
</head>

<body lang="zh-cn">
 	 <div class="wrapper">	
	<div class="container-fluid">
		<div class="row-fluid">
			<!--/span-->
			<div class="span12">
			<h3 align="center">修改密码</h3>
				<form class="form-horizontal" name="managerForm" id="managerForm" method="post">
					<input type="hidden" id="memberId" name="memberId" value="${member.id }">
						<table style="width:100%;">
							<tr>
								<th colspan="2"><span id="managerSuccessSpan"></span>
								</th>
							</tr>
							<tr>
								<th style="height:40px;">旧密码:</th>
								<td>
									<input type="password" id="oldPsw" name="oldPsw"
										style="width:180px;height:30px;font-size:16px">
								</td>
							</tr>
							<tr>
								<th style="height:40px;">新密码:</th>
								<td>
									<input type="password" id="newPsw" name="newPsw"
										style="width:180px;height:30px;font-size:16px">
								</td>
							</tr>
							<tr>
								<th style="height:40px;">确认密码:</th>
								<td>
									<input type="password" id="confirmPsw"
										style="width:180px;height:30px;font-size:16px">
								</td>
							</tr>
							<tr>
								<td colspan="2" style="height:40px;">
								  <div align="center">
									<button type="button" class="btn btn-primary" id="commitMember">提交</button>
									&nbsp;&nbsp;&nbsp;
									<a class="btn btn-primary" href="wumimember/memberaction!updateReturnMemberPage?member.eaId=${member.eaId }">返回主页</a>
								  </div>
								</td>
							</tr>
						</table>
				</form>
			</div>
		</div>
	</div>
	<div class="push"></div>
    </div>
	<c:import url="/jsp/commons/footer.jsp"></c:import>
</body>

<script type="text/javascript">
	$(document).ready(function() {
		$("#commitMember").click(function() {
			var oldPsw = $("#oldPsw").val();
			if (oldPsw.length == 0) {
				alert("请输入旧密码");
				return false;
			}
			
			var newPsw = $("#newPsw").val();
			var confirmPsw = $("#confirmPsw").val();
			if (newPsw.length == 0) {
				alert("请输入新密码");
				return false;
			}
			if (confirmPsw.length == 0) {
				alert("请输入确认密码");
				return false;
			}
			if (newPsw != confirmPsw) {
				alert("两次输入密码不一致");
				return false;
			}
			
			$("#oldPsw").val(faultylabs.MD5(oldPsw));
			$("#newPsw").val(faultylabs.MD5(newPsw));
			$("#confirmPsw").val(faultylabs.MD5(confirmPsw));
			
			$.ajax({
				type: "POST",
				url:"wumimember/memberaction!modifyPassword",
				data:$("#managerForm").serialize(),
				dataType:"json",
				error: function(request) {
					alert("Connection error");
				},
				success: function(data) {
					var d = eval("("+data+")");
					if (d != null) {
						$("#oldPsw").val("");
						$("#newPsw").val("");
						$("#confirmPsw").val("");
						alert(d.temp);
					}
				}
			});
		});
	}); 
</script>
</html>
